package com.wll.design.观察者.eventbus;

import com.google.common.eventbus.EventBus;

/**
 * @ClassName: EventBusCenter.java
 * @author: wanglulu
 * @version: 1.0.0
 * @Description: 事件 广播
 * @createTime: 2021/11/25 15:43
 */
public class EventBusCenter {

    private static EventBus eventBus = new EventBus();

    private EventBusCenter() {
    }

    public static EventBus getInstance() {
        return eventBus;
    }

    //添加观察者
    public static void register(Object obj) {
        eventBus.register(obj);
    }

    //移除观察者
    public static void unregister(Object obj) {
        eventBus.unregister(obj);
    }

    //把消息推给观察者
    public static void post(Object obj) {
        eventBus.post(obj);
    }
}
